Skip to content

Fixing integ tests (ReplicationEngine now constructs lightweight copies of Index / Delete operations with Origin.REPLICA before passing them to the non-primary planning path)#1647

Merged
peterzhuamazon merged 3 commits into
opensearch-project:mainfrom
mohit10011999:main
Mar 25, 2026
Merged

Fixing integ tests (ReplicationEngine now constructs lightweight copies of Index / Delete operations with Origin.REPLICA before passing them to the non-primary planning path)#1647
peterzhuamazon merged 3 commits into
opensearch-project:mainfrom
mohit10011999:main

Conversation

@mohit10011999
Copy link
Copy Markdown
Contributor

@mohit10011999 mohit10011999 commented Mar 24, 2026

Description

OpenSearch #20585 (commit 59be6ae) refactored InternalEngine by extracting IndexingStrategy and DeletionStrategy from inner static classes into top-level classes, and introduced IndexingStrategyPlanner / DeletionStrategyPlanner to encapsulate planning logic. This broke CCR's ReplicationEngine in two ways:

Compilation failure: IndexingStrategy and DeletionStrategy are no longer inner classes of InternalEngine — they need explicit imports from org.opensearch.index.engine.

Runtime assertion failures: The new planner classes have their own assertNonPrimaryOrigin check (via the OperationStrategyPlanner interface default method), which is separate from InternalEngine.assertNonPrimaryOrigin. CCR's ReplicationEngine overrode the engine-level method to return true, but that override is never invoked by the planner. Since CCR replays operations with Origin.PRIMARY (they arrive via TransportReplayChangesAction.performOnPrimary) but routes them through planIndexingAsNonPrimary / planDeletionAsNonPrimary, the planner's assertion fires.

Fix

ReplicationEngine now constructs lightweight copies of Index / Delete operations with Origin.REPLICA before passing them to the non-primary planning path. This satisfies the assertions at both the engine level and the planner level. The copies also use null for versionType and unassigned values for ifSeqNo / ifPrimaryTerm, as the Engine$Index and Engine$Delete constructors enforce these constraints for non-PRIMARY origins. This is safe because the non-primary planning path resolves conflicts using sequence numbers, not version types or conditional (optimistic concurrency) parameters.

The actual indexing/deletion still operates on the original operation objects — only the strategy planning step sees the replica copies.

Related Issues

Resolves #1646

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Copy Markdown
Member

@ankitkala ankitkala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the diff. right now the ordering of methods is messed up. so identifying diff becomes difficult.

Signed-off-by: Mohit Kumar <mohitamg@amazon.com>
This reverts commit 0e4b126.

Signed-off-by: Mohit Kumar <mohitamg@amazon.com>
Signed-off-by: Mohit Kumar <mohitamg@amazon.com>
Comment thread src/main/kotlin/org/opensearch/replication/ReplicationEngine.kt
@mohit10011999 mohit10011999 changed the title Stab at Fixing integ tests Fixing integ tests (ReplicationEngine now constructs lightweight copies of Index / Delete operations with Origin.REPLICA before passing them to the non-primary planning path) Mar 24, 2026
@peterzhuamazon peterzhuamazon merged commit 515abbc into opensearch-project:main Mar 25, 2026
17 checks passed
tanyabti pushed a commit to tanyabti/cross-cluster-replication that referenced this pull request Apr 9, 2026
…es of Index / Delete operations with Origin.REPLICA before passing them to the non-primary planning path) (opensearch-project#1647)

* Stab at Fixing integ tests

Signed-off-by: Mohit Kumar <mohitamg@amazon.com>

* Revert "Stab at Fixing integ tests"

This reverts commit 0e4b126.

Signed-off-by: Mohit Kumar <mohitamg@amazon.com>

* Stab at Fixing integ tests

Signed-off-by: Mohit Kumar <mohitamg@amazon.com>

---------

Signed-off-by: Mohit Kumar <mohitamg@amazon.com>
Co-authored-by: Mohit Kumar <mohitamg@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Plugin is not compatible with the latest OpenSearch 3.6.0-SNAPSHOT

5 participants